{extend name="public/base"}

{block name="x-body"}
<div class="x-body">
    <div class="layui-row">
        <blockquote class="layui-elem-quote">
            <span style="color: red;">提示：优惠券类型为下单赠送时，发送优惠券功能失效</span>
        </blockquote>
    </div>
    <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll('{:url(\'promotion/coupon_del\')}')"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show('添加会员','{:url(\'promotion/coupon_form\')}')"><i class="layui-icon"></i>添加</button>
        <span class="x-right" style="line-height:40px">共有数据：{$list -> total()} 条</span>
    </xblock>
    <table class="layui-table layui-form">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>优惠券名称</th>
            <th>优惠券类型</th>
            <th>优惠券金额</th>
            <th>使用条件</th>
            <th>发放总量</th>
            <th>已发放数</th>
            <th>已使用</th>
            <th>使用截止日期</th>
            <th width="50" style="text-align: center;">状态</th>
            <th>操作</th>
        </thead>
        <tbody>
        {volist name="list" id="v"}
        <tr>
            <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$v.id}'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td>{$v.id}</td>
            <td>{$v.name}</td>
            <td>{if $v.type == 0}下单赠送{elseif $v.type == 1}指定发放{else /}免费领取{/if}</td>
            <td>{$v.money}</td>
            <td>{$v.condition}</td>
            <td>{$v.createnum}</td>
            <td>{$v.send_num}</td>
            <td>{$v.use_num}</td>
            <td>{$v.use_end_time|date="Y-m-d"}</td>
            <td>
                <input class="check" type="checkbox" name="status" data-id="{$v.id}" data-status="{$v.status}" lay-text="是|否" {if $v.status == 1}checked=""{/if} lay-skin="switch">
            </td>
            <td class="td-manage">
                <a title="发放优惠券" {if $v.type != 0}onclick="x_admin_show('发放优惠券', '{:url(\'promotion/coupon_send\', [\'id\' => $v.id])}')"{/if} href="javascript:;">
                    <i class="layui-icon">&#xe609;</i>
                </a>
                <a title="编辑"  onclick="x_admin_show('编辑会员', '{:url(\'promotion/coupon_form\', [\'id\' => $v.id])}')" href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" onclick="member_del(this,'{$v.id}', '{:url(\'promotion/coupon_del\')}')" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>
                </a>
                <a title="查看优惠券" onclick="load_url('{:url(\'promotion/coupon_cat\', [\'id\' => $v.id])}')" href="javascript:;">
                    <i class="layui-icon">&#xe674;</i>
                </a>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page">
        {$list -> render()|raw}
    </div>

</div>

<script>
    /**
     * 更新状态
     */
    editStatus('{:url("promotion/coupon_status")}');
</script>
{/block}